const { list, tag } = require('./mock')

module.exports = app => {

	app.get('/api/list', (req, res) => {
		const { pageCode = 1, pageSize = 10 } = req.query;

		if(pageCode * pageSize <= list.length) {
			res.send({
				code: 200,
				data: list.slice((pageCode - 1) * pageSize, pageCode * pageSize)
			})
		} else {
			res.send({
				code: 201,
				data: null,
				message: '没有更多数据了！'
			})
		}
	})

	app.get('/api/tag/all', (req, res) => {
		res.send({
			code: 200,
			data: tag
		})
	})
}